package com.sf.dlb.utils;


import com.sf.dlb.vo.ResultVO;

/**
 * 返回VO处理
 *
 * Created by jing.tan on 2018/12/10.
 */
public class ResultVOUtil {

    public static ResultVO success(Object object) {
        ResultVO resultVO = new ResultVO<>();
        resultVO.setData(object);
        resultVO.setCode(200);
        resultVO.setMsg("成功");
        return resultVO;
    }
    public static ResultVO successEncryption(Object object) {
        ResultVO resultVO = new ResultVO<>();
        String dataStr=AES256EncryptionUtils.getInstance().encrypt(GsonUtils.getInstance().toJson(object));
        resultVO.setData(dataStr);
        resultVO.setCode(200);
        resultVO.setMsg("成功");
        return resultVO;
    }
    public static void successEncryption(ResultVO resultVO) {
        Object object=resultVO.getData();
        String dataStr=AES256EncryptionUtils.getInstance().encrypt(GsonUtils.getInstance().toJson(object));
        resultVO.setData(dataStr);
    }

    public static ResultVO success() {
        return success(null);
    }

    public static ResultVO error(Integer code, String msg) {
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(code);
        resultVO.setMsg(msg);
        return resultVO;
    }
}
